"""
The SigmoidActivation class implements the sigmoid activation function.
"""
import numpy as np

class SigmoidActivation:

    def __init__(self):
        """
        No initialization necessary.
        """
        pass

    def forward_pass(self, batch_values):
        """
        Compute the sigmoid activation for the input values.
        Sigmoid function: f(x) = 1 / (1 + e^(-x))
        """
        self.inputs = batch_values
        # in this case we save the outputs because we can reuse them for
        # the backward pass
        self.outputs = 1 / (1 + np.exp(-batch_values))
        return self.outputs
    
    def backward_pass(self, dvalues):
        """
        Compute the gradient of the loss with respect to the input values.
        The derivative of the sigmoid function is f'(x) = f(x) * (1 - f(x))
        """
        self.dvalues = dvalues * (self.outputs * (1 - self.outputs))
        return self.dvalues